package com.yuzai.reading.commons.handle;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.yuzai.reading.commons.exception.TokenParseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(TokenParseException.class)
    public Object handleException(TokenParseException tokenParseException) {
        String msg = tokenParseException.getMessage();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 401);
        jsonObject.put("data", "");
        jsonObject.put("message", msg);
        return jsonObject;
    }


}
